<?php
/*
	本插件：$this->model('model')->方法名();
	其他地方调用：model('jy_aliesign/model')->方法名();
	//小程序支付唤起预授权：https://opendocs.alipay.com/mini/api/openapi-pay?pathHash=e964f41e
*/
namespace jy_aliesign;
defined('BY_JYA') or exit('error');
class model extends \plugin{
	public function signlog($paylog,$flow_id=''){
		$signlog=array(
			'uniacid'=>$paylog['uniacid'],
			'mid'=>$paylog['mid'],
			'payid'=>$paylog['id'],
			'flow_id'=>$flow_id,
			'createtime'=>TIMESTAMP,
			'status'=>0,
		);
		pdo_insert('jy_aliesign_log',$signlog);
		return '';
	}
	public function uplog($flow_id='',$status=0){
		$log=pdo_get('jy_aliesign_log',array('uniacid'=>$_SESSION['uniacid'],'flow_id'=>$flow_id));
		$order=pdo_get('jy_weishop_order',array('pay_id'=>$log['payid'],'uniacid'=>$_SESSION['uniacid']));
		if($order){
			$order['api_data']=json_decode($order['api_data'],true);
			$order['api_data']['esignok']=1;
			pdo_update('jy_weishop_order',array('api_data'=>ijson_encode($order['api_data'])),array('id'=>$order['id'],'uniacid'=>$_SESSION['uniacid']));
		}
		pdo_update('jy_aliesign_log',array('status'=>$status),array('uniacid'=>$_SESSION['uniacid'],'flow_id'=>$flow_id));
		return '';
	}
}
?>